/*
 * EquipmentSuperShield.cpp
 *
 *  Created on: 23/06/2012
 *      Author: federico
 */

#include "EquipmentSuperShield.h"
#include "../PlayScenarioPanel.h"


#define SUPER_SHIELD_IMAGE "./resources/img/objetos/superShield.png"

EquipmentSuperShield::EquipmentSuperShield(Widget* parent) : Equipment(SUPER_SHIELD,parent) {
	this->surface = SurfaceUtils::loadImage(SUPER_SHIELD_IMAGE);
	this->energy = new ProgressBar(100,0,0,this->parent);
}

EquipmentSuperShield::EquipmentSuperShield(DTOEquipment* dtoEquipment,Widget* parent):
Equipment(dtoEquipment->bonusType, parent){
	this->surface = SurfaceUtils::loadImage(SUPER_SHIELD_IMAGE);
	this->energy = new ProgressBar(dtoEquipment->value,0,0,this->parent);
}

void EquipmentSuperShield::handleEvent(Event event){
	//Nada, el shield no maneja eventos, previene de los ammo
}
void EquipmentSuperShield::updateStatus(){
	//Nada, el shield no se actualiza ni muere
}

int EquipmentSuperShield::reduceLife(int value,playElement element){
	return (element == AMMO) ? 0 : value;
}

void EquipmentSuperShield::showOn(SDL_Surface* surface,int offsetX,int offsetY) {
	if(energy->getPorcent() == 0){
		emptyFlag = false;
	}else{
		SDL_Rect rect = this->surface->clip_rect;
		rect.x = offsetX - rect.w / 2;
		rect.y = offsetY - rect.h / 2;
		SDL_BlitSurface(this->surface, NULL, surface, &rect);
		//No se dibuja la energyBar
	}
}

DTOEquipment* EquipmentSuperShield::getDTO() {
	return new DTOEquipment(SUPER_SHIELD,this->energy->getPorcent(),((PlayScenarioPanel*)parent)->getOwner());
}

EquipmentSuperShield::~EquipmentSuperShield() {}

